package top.wardyan.wmes.constant;

import java.util.HashMap;
import java.util.Map;

import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;

/**
 * RFID用途
 * @author harrydeep@wardyan.top
 * 2021年12月18日
 */
public enum UseType {
//		/** 1 生产 **/
//		PRODUCE			(1)
//		
//		/** 2 流转 **/
//		, MOVE			(2)
//		
//		/** 3 仓储 **/
//		, WAREHOUSE	(3)
//		
//		/** 4 固定资产 **/
//		
//		/** 5 人事 **/
//		, HR			(5)
//		
		// 具体到每一个功能	// 暂时先实现生产
		
		/** 101 个人计件收回 **/
		PROD_RECEIVE_PERSONAL		(101, findName("PROD_RECEIVE_PERSONAL", "交货"))
		
		/** 102 小组集体计件收回 **/
		, PROD_RECEIVE_TEAM		(102, findName("PROD_RECEIVE_TEAM", "集体计件"))
		
		/** 103 小组计件收回产量分摊 **/
		, PROD_RECEIVE_TEAM_SHARE	(103, findName("PROD_RECEIVE_TEAM_SHARE", "小组分摊"))
		
		/** 104 计件登记 【梭织】 **/
		, PROD_RECEIVE_PIECE		(104, findName("PROD_RECEIVE_PIECE", "计件登记"))

		/** 105 计件登记 【毛织】 **/
		, PROD_RECEIVE_PIECE_WOOL	(105, findName("PROD_RECEIVE_PIECE_WOOL", "计件登记"))
		
		/** 106 返工 **/
		, PROD_RECEIVE_REDOR		(106, findName("PROD_RECEIVE_REDOR", "返工"))
		
		/** 121 QC登记 (通用) **/
		, PROD_QC					(121, findName("PROD_QC", "QC"))
		
		/** 122 疵点登记 **/
		, PROD_QC_REASON			(122, findName("PROD_QC_REASON", "疵点"))
		
		/** 123 疵点分摊登记 **/
		, PROD_QC_REASON_SHARE	(123, findName("PROD_QC_REASON_SHARE", "疵点分摊"))
		
		/** 124 返工拆扎 **/
		, PROD_QC_SPLIT			(124, findName("PROD_QC_SPLIT", "返工拆扎"))
		
		/** 125 次品登记 **/
		, PROD_QC_DEFECT			(125, findName("PROD_QC_DEFECT", "次品"))

		/** 131 车间发出【毛衣】 **/
		, PROD_WORKSHOP_ISSUE		(131, findName("PROD_WORKSHOP_ISSUE", "发出"))
		
		/** 132 车间收回【毛衣】 **/
		, PROD_WORKSHOP_RECEIVE	(132, findName("PROD_WORKSHOP_RECEIVE", "收回"))
		
		/** 133 车间取消发出【毛衣】 **/
		, PROD_WORKSHOP_CANCEL	(133, findName("PROD_WORKSHOP_CANCEL", "取消发出"))
		
		/** 134 车间返工【毛衣】 **/
		, PROD_WORKSHOP_REDOR		(134, findName("PROD_WORKSHOP_REDOR", "返工"))

		/** 141 委外发出 **/
		, PROD_FTY_ISSUE			(141, findName("PROD_FTY_ISSUE", "委外发出"))
		
		/** 142 委外收回 **/
		, PROD_FTY_RECEIVE		(142, findName("PROD_FTY_RECEIVE", "委外收回"))
		
		/** 143 委外退回 **/
		, PROD_FTY_CANCEL			(143, findName("PROD_FTY_CANCEL", "委外退回"))
		
		/** 144 委外返工 **/
		, PROD_FTY_REDOR			(144, findName("PROD_FTY_REDOR", "委外返工"))
		;
		
		
		
		
		
		
		
		
		
		
		
		Integer id;
		String name;
		
		private UseType(Integer id, String name) {
			this.id = id;
			this.name = name;
		}

		private static final Map<Integer, UseType> LISTS = new HashMap<>() {{
			for(var v : UseType.values()) {
				put(v.getId(), v);
			}
		}};
		
		public static UseType get(Integer id) {
			return LISTS.get(id);
		}
		
		static Prop config = PropKit.use("rfidfunction.txt");
		
		private static String findName(String key, String defaultName) {
			//config = PropKit.use("rfidfunction.txt");
			if(config == null) {
				config = PropKit.use("rfidfunction.txt");
			}
			String n = config.get("key");
			return n == null || n.equals("") ? defaultName : n;
		}
		
		
		
		
		
		
		
		
		public Integer getId() {
			return id;
		}

		public UseType setId(Integer id) {
			this.id = id;
			return this;
		}
		
		public String getName() {
			return name;
		}

		public UseType setName(String name) {
			this.name = name;
			return this;
		}
		

}
